package controllers

import (
	"blog/models"
	"github.com/astaxie/beego"
)

// ContactController operations for Contact
type ContactController struct {
	beego.Controller
}

func (c *ContactController) Index() {
	var fields []string
	var sortby []string
	var order []string
	var query = make(map[string]string)
	var limit int64 = 10
	var offset int64

	categories, err := models.GetAllArticle_category(query, fields, sortby, order, offset, limit)
	if err != nil {
		c.Abort("404")
	} else {
		c.Data["Categories"] = categories
	}
	limit = 3
	recent, err := models.GetAllArticle(query, fields, sortby, order, offset, limit)
	if err != nil {
		c.Abort("404")
	} else {
		c.Data["Recent"] = recent
	}

	c.Data["Title"] = "联系我"
	c.Layout = "contact/contact_layout.tpl"
	c.TplName = "contact/contact_content.tpl"
	c.LayoutSections = make(map[string]string)
	c.LayoutSections["Head"] = "common/head.tpl"
	c.LayoutSections["Menu"] = "common/menu.tpl"
	c.LayoutSections["Footer"] = "common/footer.tpl"
	c.LayoutSections["Script"] = "common/script.tpl"
	c.LayoutSections["OtherScript"] = "contact/contact_script.tpl"
	c.LayoutSections["OtherHead"] = "contact/contact_head.tpl"
	c.LayoutSections["Aside"] = "common/aside.tpl"
}
